package www.rlicker.service.impl;

import www.rlicker.model.Banner;

import java.util.Map;

import javax.annotation.Resource;

import www.rlicker.dao.IBannerDao;

import org.springframework.stereotype.Service;

import www.rlicker.mybatis.Criteria;
import www.rlicker.service.IBannerService;
import www.rlicker.utils.MessageConstant;
import www.rlicker.utils.TranslateToMap;

import java.util.List;

@Service
public class BannerServiceImpl implements IBannerService{


	public List<Map<String, Object>>  queryPage (Criteria<Banner> param){
		List<Banner> list = bannerRepository.queryPage(param);
			List<Map<String,Object>> map = TranslateToMap.convertListBean2ListMap(list,Banner.class);
	return map;  }

	public Integer queryPageCount (Criteria<Banner> param){
		return (Integer) bannerRepository.queryPageCount(param);
	}

	public Banner  queryEntity (Long id ){
		return bannerRepository.queryEntity(id);
	}

	public String deleteById (Long id ){
		int result = bannerRepository.deleteById(id);
			if ( result != 1) {
					return MessageConstant.USER_TYPE_3;
			}
			return null;
	}

	public String insert(Banner record ){
		int result = bannerRepository.insert(record);
			if ( result != 1) { 
					return MessageConstant.USER_TYPE_4;
			}
			return null;
	}

	public String update (Criteria<Banner> param){
		int result = bannerRepository.update(param);
			if ( result != 1) { 
					return MessageConstant.USER_TYPE_5;
			}
			return null;
	}

	@Resource
	private IBannerDao bannerRepository;

}